# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-ppx_deriving
_pkgname=ppx_deriving
pkgver=5.2.1
pkgrel=1
pkgdesc="Type-driven code generation for OCaml"
url="https://github.com/ocaml-ppx/ppx_deriving"
arch="all !riscv64"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime ocaml-ppxlib ocaml-result"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-ppxlib-dev ocaml-result-dev"
makedepends="$depends_dev dune ocaml ocaml-cppo ocaml-findlib-dev"
checkdepends="ocaml-ounit-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/ocaml-ppx/ppx_deriving/releases/download/v$pkgver/ppx_deriving-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
f28cd778a2d48ababa53f73131b25229a11b03685610d020b7b9228b1e25570891cd927b37475aeda49be72debaf5f2dda4c1518a0965db7a361c0ebe325a8d2  ocaml-ppx_deriving-5.2.1.tar.bz2
"
